package com.example.activiti.controller;

import com.example.activiti.common.core.controller.BaseController;
import com.example.activiti.common.core.domain.AjaxResult;
import com.example.activiti.leave.domain.WorkflowData;
import com.example.activiti.service.IProcessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 汇讯数码科技(深圳)有限公司
 * 创建日期:2020/10/22-15:16
 * 版本   开发者     日期
 * 1.0    Danny    2020/10/22
 *
 * @author ruoyi
 */
@Slf4j
@RestController
@RequestMapping("/process")
public class ProcessController extends BaseController {

    @Resource
    private IProcessService processService;

    /**
     * 1.根据processDefinitionKey和其他数据启动流程（任务）
     */
    @PostMapping(value = "/start")
    public AjaxResult processStart(@RequestBody WorkflowData workflowData) {
        Map<String, String> map = processService.processStart(workflowData);
        log.info("processStart Data: {}", map.toString());
        return toAjax(map.size());
    }


}
